DCon - The Ultimate Debugging Console
1998 Phasic Interware,  1998 Cache Computing
http://www.cache-computing.com/products/dcon
mailto:dcon@cache-computing.com





Function - dopen

     void dopen(const char *log);

Description

The dopen function redirects the output from the dprintf, vdprintf and dprintmem functions to the log file named the its c-style string argument.  A value of NULL may be specified to redirect output back to the console window.  Note, a non-obvious side affect of redirecting output to a log file is that it will no longer be displayed in the console window unless the 'Echo log files to console' preference is checked.

Examples

To redirect all dprintf, vdprintf and dprintmem output to the file "MyApp.log":
     dopen("MyApp.log");

To redirect all dprintf, vdprintf and dprintmem output back to the console window:
     dopen(NULL);





Function - dprintf, dfprintf, vdprintf, vdfprintf

     void dprintf(const char *format, ...);
     void dfprintf(const char *log, const char *format, ...);
     void vdprintf(const char *format, va_list arg);
     void vdfprintf(const char *log, const char *format, va_list arg);

Description

The dprintf family of functions produces output according to a c-style format string.  The format string specifies how subsequent arguments (or arguments accessed via the variable-length argument facilities of stdarg for vdprintf and vdfprintf) are converted into output.  The functions dprintf and vdprintf write output to the console window. The functions dfprintf and vdfprintf write output to the log file named by the first c-style string argument.

Examples

To output a pascal string and print its length to the log file named "debug.log":
     StringPtr pstr = "\pHello World!";
     dfprintf("debug.log","%#s contains %d chars\n", pstr, pstr[0]);

To output a date and time in the form "Sunday, July 3, 10:02", where weekday and month are pointers to c-style strings and day, hour and min are integers:
     dprintf("%s, %s %d, %.2d:%.2d\n", weekday, month, day, hour, min);





Function - dprintmem, dfprintmem

     void dprintmem(const void *data,size_t len);
     void dfprintmem(const char *log,const void *data,size_t len);

Description

The dprintmem family of function outputs a formatted hexadecimal and ASCII dump of a block of memory.

Examples

To dump the first 16 bytes of the System Heap as raw data:
     dprintmem((Ptr)0x2800,16);

     Displaying 16 bytes from 00002800
     00002800  00AF 9B60 009B B7E0  0069 6730 0012 79B0  '...`.....ig0..y.'





Macro - DCON

     #define DCON 0
     #define DCON 1

Description

The DCON macro allows the C preprocessor to strip all DCon function calls out of compiled code.  The default behavior is to include DCon function calls, by adding a #define DCON 0 before inclusion of the DCon.h header file all DCon function calls will be converted into statements that produce no runtime code.  The default behavior of the DCON macro can be altered by change its value in the DCon.h header file.

Examples

To disable DCon function calls in a single file:
     #define DCON 0
     #include "DCon.h"





Macro - dAssert

     dAssert(conditional_expression)

Description

The dAssert macro prints an error message to the console window if the conditional_expression is false  (i.e., compares equal to zero).  The dAssert macro uses the dprintf function to output and is subject to the redirection effects of the dopen function.  The dAssert macro only generates runtime code when the DCON macro is defined to be 1.

Examples

To generate an error message when a pointer argument is unexpectedly NULL:
     void Foo(const char *bar) {
        dAssert(bar != NULL);

